#!/bin/sh
sudo chmod 777 * -Rf
sudo chown `whoami` * -Rf

module=$1
profile=${2:-'test'}

source_path=/data/code/kylin-plugin-fintech
target_path=/data/services/deploy/kylin-plugin-fintech

init(){
	mkdir -p $target_path
}

build(){
	echo "build $profile...."
	git pull
	mvn clean package -DskipTests

	cp -f $source_path/kylin-$module/target/kylin-${module}.tar.gz $target_path
	cp -f $source_path/deploy.sh $target_path
}

deploy(){
	sudo sh $target_path/deploy.sh $module $profile
}
case x$module in
    "xfintech-admin"| "xfintech-restful")
        case $profile in     
		test|youxuan|yanxuan|jinmao|nandu)
 			init
			build			
			deploy
        		echo "build success!"
          		exit
			;;
             *)
                ;;
        esac
	;;
    *)
    echo "build [ fintech-admin | fintech-restful ]  [test | youxuan | jinmao ]"
    exit
    ;;
esac

